package com.yyfax.pay.depository.vo;

import java.util.List;

import com.yyfax.pay.common.enums.FuiouDepositStateEnum;
import com.yyfax.pay.common.exception.PayExceptionCode;
import com.yyfax.pay.depository.domain.FuiouFileDownload;
import com.yyfax.pay.depository.domain.FuiouFileDownloadDetail;

/**
 * 富友存管文件快照类
 * 
 * @author buyi
 * @date 2017-09-06 09:43:37
 * @since v2.0.0
 */
public class FuiouDownloadFileVO {
	private FuiouFileDownload po;
	private List<FuiouFileDownloadDetail> list;

	/**
	 * 新建实例
	 * 
	 * @author buyi
	 * @date 2017-09-30 10:01:43
	 * @since v2.0.0
	 * @param po
	 * @param list
	 * @return
	 */
	public static FuiouDownloadFileVO newInstance(FuiouFileDownload po, List<FuiouFileDownloadDetail> list) {
		if (po == null || list == null || list.isEmpty()) {
			throw PayExceptionCode.ERROR_ILL_PARAMETER.exp("参数po/list不能为空");
		}

		return new FuiouDownloadFileVO(po, list);
	}

	private FuiouDownloadFileVO(FuiouFileDownload po, List<FuiouFileDownloadDetail> list) {
		super();
		this.po = po;
		this.list = list;
	}

	public FuiouFileDownload getPo() {
		return po;
	}

	public void setPo(FuiouFileDownload po) {
		this.po = po;
	}

	public List<FuiouFileDownloadDetail> getList() {
		return list;
	}

	public void setList(List<FuiouFileDownloadDetail> list) {
		this.list = list;
	}

	/**
	 * 是否可执行下载
	 * 
	 * @author buyi
	 * @date 2017-09-21 19:00:00
	 * @since v2.0.0
	 * @return
	 */
	public boolean isDo() {
		if (po == null) {
			throw PayExceptionCode.ERROR_ILL_PARAMETER.exp();
		}

		if (FuiouDepositStateEnum.INI.isValue(po.getState())|| FuiouDepositStateEnum.TIMEOUT.isValue(po.getState())) {
			return true;
		}

		return false;
	}
}
